package com.hh.game.service.gateway.filter.ip;

import cn.hutool.core.collection.ConcurrentHashSet;

import java.util.Set;

public class RateLimitConfig {
    private Set<String> BLACk_IP_SET = new ConcurrentHashSet<>();

    private int qps; //ip最大qps
    private int limit;//超过qps进入黑名单次数

    public void clearBlackIP(){
        BLACk_IP_SET.clear();
    }

    public boolean removeBlackIP(String ip){
        return BLACk_IP_SET.remove(ip);
    }

    public boolean addBlackIP(String ip){
        return BLACk_IP_SET.add(ip);
    }

    public boolean isBlackIP(String ip){
        return BLACk_IP_SET.contains(ip);
    }

    public int getQps() {
        return qps;
    }

    public void setQps(int qps) {
        this.qps = qps;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }
}
